package com.tom.mybatis.config;

import com.tom.mybatis.bean.Test;

import java.util.HashMap;
import java.util.Map;

/**
 * @author : tom
 * @project: tom-mybatis
 * @date : 2018/11/7 14:48
 */
public class MapperRegistory {

    public static final Map<String, MapperDate> methodSqlMapping = new HashMap<String, MapperDate>();

    public MapperRegistory() {
        methodSqlMapping.put("com.tom.mybatis.config.mappers.TestMapper.selectByPrimaryKey",
                new MapperDate("select * from test where id = %d",Test.class));
    }

    public MapperDate get(String nameSpace) {
        return methodSqlMapping.get(nameSpace);
    }

    public class MapperDate<T> {
        private String sql;

        private Class<T> type;

        public MapperDate(String sql, Class<T> type) {
            this.sql = sql;
            this.type = type;
        }

        public String getSql() {
            return sql;
        }

        public void setSql(String sql) {
            this.sql = sql;
        }

        public Class<T> getType() {
            return type;
        }

        public void setType(Class<T> type) {
            this.type = type;
        }
    }
}
